import request from '@/router/axios'

const prefix = '/api/blade-workflow/design/deployment'
const build = '/api/blade-workflow/build/customize'

export const getList = (current, size, params) => {
  return request({
    url: `${prefix}/list`,
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const remove = (data) => {
  return request({
    url: `${prefix}/remove`,
    method: 'post',
    data
  })
}

export const changeStatus = (data) => {
  return request({
    url: `${prefix}/changeStatus`,
    method: 'post',
    data
  })
}

export const changeCategory = (data) => {
  return request({
    url: `${prefix}/changeCategory`,
    method: 'post',
    data
  })
}

export const getDeploymentListByKey = (key, name) => {
  return request({
    url: `${prefix}/getDeploymentListByKey`,
    method: 'get',
    params:{
      key,
      name
    }
  })
}

export const buildFlow = (data) => {
  return request({
    url: `${build}/buildFlow`,
    method: 'post',
    data
  })
}

export const saveActivityLinkName = (data) => {
  return request({
    url: `${build}/saveActivityLinkName`,
    method: 'post',
    data
  })
}

export const getActivityLinkName = (linkItemId) => {
  return request({
    url: `${build}/getActivityLinkName`,
    method: 'get',
    params:{
      linkItemId
    }
  })
}

export const deleteActivity = (linkItemId) => {
  return request({
    url: `${build}/deleteActivity`,
    method: 'post',
    params:{
      linkItemId
    }
  })
}

export const updateActivityDeploymentId = (modelKey, deploymentId) => {
  return request({
    url: `${build}/updateActivityDeploymentId`,
    method: 'post',
    params:{
      modelKey,
      deploymentId
    }
  })
}

export const selectActivityPage = (current, size, params) => {
  return request({
    url: `${build}/selectActivityPage`,
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const selectActivityVersionPage = (current, size, params) => {
  return request({
    url: `${build}/selectActivityVersionPage`,
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
